<extend name="Public:innerbase" />
<block name="js">
<include file="Public:upload" />
<include file="Public:editor" />
<script type="text/javascript">
	$(function(){
		function check(el){
			if($(el).is(':checked')){
				$('#signEndTime').show();
			}
			else $('#signEndTime').hide();
		}
		check($('#onlineSign'));
		$('#onlineSign').change(function(){
			check(this);
		});
	});
function showChildCats(value){
	$("#catid").html('<option value="0">请选择...</option>');
	if(value==0){
		document.getElementById('catid').disabled=true;
	}else{
		$.ajax({
			url: $('#catUrl').attr("value")+'&parentid='+value,
			success: function( data ) {
				document.getElementById('catid').disabled=false;
				$("#catid").html($("#catid").html()+data);
			}
		});
	}
}

function toDecimal(x) {  
	var f = parseFloat(x);  
	if (isNaN(f)) {  
		return;  
	}  
	f = Math.round(x*10)/10;  
	return f;  
}

function calDiscount(){
	var price=$('#price').attr('value');
	var oprice=$('#oprice').attr('value');
	if(oprice!=0&&oprice!=''){
		var dis=oprice-price;
		var discount=10-toDecimal((dis/oprice)*10);
	}else{
		discount=10;
	}
	$('#discount').attr('value',discount);
}
</script>
</block>
<block name="content">
<div class="container-fluid">
	<div class="page-header wm-page-header">
		<h4>商品设置</h4>
		<a href="{:U('Product/index')}" class="btn btn-default btn-sm">
			<span class="glyphicon glyphicon-chevron-left"></span>&nbsp;返回
		</a>
	</div>
	<form class="form-horizontal" method="post">
		<input type="hidden" name="id" value="{$set.id}" />
		<input type="hidden" name="discount" id="discount" value="{$set.discount}" />
		<div class="form-group">
			<label class="col-sm-2">名称</label>
			<div class="col-md-4">
				<input type="text" name="name" value="{$set.name}" class="form-control" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">分类</label>
			<div class="col-md-2">
				<select id="catid" name="catid" class="form-control">
					<option value="0">请选择分类...</option>
					{$catsOptions}
				</select>
			</div>
		</div>
		<div class="form-group" style="display:none;">
			<label class="col-sm-2">店铺</label>
			<div class="col-md-4">
				<input type="text" name="storeid" value="{$set.name}" class="form-control" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">价格</label>
			<div class="col-md-2">
				<div class="input-group">
					<input type="text" id="price" onchange="calDiscount();" name="price" value="{$set.price}" class="form-control" />
					<span class="input-group-addon">元</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">原价</label>
			<div class="col-md-2">
				<div class="input-group">
					<input type="text" id="oprice" onchange="calDiscount();" name="oprice" value="{$set.oprice}" class="form-control" />
					<span class="input-group-addon">元</span>
				</div>
			</div>
		</div>
		<div class="form-group">
					<label class="col-sm-2">颜色</label>
					<div class="col-md-5">
						<input type="input" class="form-control" id="color"  name="color"  value="{$set.color}"/>
					</div>
					<span class="col-md-5 text-info">多个颜色请以输入法为英文状态下逗号分隔!</span>
				</div>
				
				<div class="form-group">
					<label class="col-sm-2">尺寸</label>
					<div class="col-md-5">
						<input type="input" class="form-control" id="size"  name="size"  value="{$set.size}"/>
					</div>
					<span class="col-md-5 text-info">多个尺寸请以输入法为英文状态下逗号分隔!</span>
				</div>
				
		<div class="form-group" style="display:none;">
			<label class="col-sm-2">关键词</label>
			<div class="col-md-4">
				<input type="text" name="keyword" value="{$set.keyword}" class="form-control" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">商品图片</label>
			<div class="col-sm-6" >
				<input type="hidden" class="form-control" value="{$set.logourl}" id="img" name="logourl" />
				<img id="imgHolder" style="width:216px;height:120px;" class="img-rounded" <if condition="$set['logourl'] eq ''">src="{:RES}/images/photo/noneimg.jpg"</if> src="{$set.logourl}"/>
				<div class="btn-group" style="vertical-align:bottom;">
					<span class="btn btn-xs btn-primary" onclick="selectAsset('img',720,400)">
						<span class="glyphicon glyphicon-cloud-upload"></span>选择
					</span>
					<span class="btn btn-primary btn-xs" onclick="previewImg('img')">
						<span class="glyphicon glyphicon-picture"></span>预览
					</span>
				</div>
			</div>
		</div>
		
		
		<div class="form-group">
					<label class="control-label col-xs-2">首页展示：</label>
					<div class="col-md-4">
						<label><input id="onlineSign" <?php if($set['onsign'])echo 'checked';?> type="checkbox" name="onsign" value="1" /></label>
					</div>
				</div>
				<div id="signEndTime">
					<div class="form-group">
					<label class="control-label col-xs-2">类型：</label>
					<div class="col-md-4">
						<label><input id="onlineSign" <?php if($set['ontype'] ==1)echo 'checked';?>  type="radio" name="ontype" value="1" />显示大图</label>
						<label><input id="onlineSign" <?php if($set['ontype'] ==2)echo 'checked';?> type="radio" name="ontype" value="2" />正常产品</label>
					</div>
				</div>
					<div class="form-group">
						<label class="col-sm-2">提醒图片：</label>
						<div class="col-md-4">
							<img id="sign_bannerHolder" style="width:216px;" class="img" src="{$set.defapic}"/>
							<input type="hidden" name="defapic" value="{$set.defapic}" class="from-control" id="sign_banner" />
							<div class="btn-group" style="vertical-align:bottom;">
								<span class="btn btn-xs btn-primary" onclick="selectAsset('sign_banner',720,400)">
									<span class="glyphicon glyphicon-cloud-upload"></span>选择
								</span>
								<span class="btn btn-primary btn-xs" onclick="previewImg('sign_banner')">
									<span class="glyphicon glyphicon-picture"></span>预览
								</span>
							</div>
						</div>
					</div>	
			</div>		
			
		<div class="form-group">
			<label class="col-sm-2">商品详细介绍</label>
			<div class="col-md-6">
				<textarea class="form-control" name="intro" id="content" rows="5" style="height:260px">{$set.intro}</textarea>
			</div>
		</div>
		<div class="form-group">
			<div class="col-md-5 col-sm-offset-2">
				<input type="submit" class="btn btn-primary" value="保存" />
			</div>
		</div>
	</form>
</div>
</block>